﻿using AutoMapper;
using ExamServer.Entities;
using ExamServer.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ExamServer.ProFile
{
    public class ExamServerProfile : Profile
    {
        public ExamServerProfile()
        {
            CreateMap<Users, UserModel>()
              .ForMember(dest => dest.Age,
                        config => config.MapFrom(
                                    src => DateTime.Now.Year - DateTime.Parse(src.Birthday).Year
                                    ));
            CreateMap<QuestionType, QuestionTypeModel>()
                .ForMember(dest=>dest.StateDisplay,
                            config=>config.MapFrom(
                                src=>src.TypeState.ToString()));
            CreateMap<Menus, MenusModel>();
            CreateMap<Users, UserEditModel>();
        }
    }
}
